home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / ibmcom_c.zip / IBMCOMT.C < prev    next >
Text File  |  1990-01-26  |  2KB  |  51 lines

  1. /*****************************************************************************
  2.  *                                 ibmcomt.c                                 *
  3.  *****************************************************************************
  4.  * DESCRIPTION: This is a simple test program for IBMCOM.  It acts like a    *
  5.  *              dump terminal at a fixed speed with no commands except Alt-X *
  6.  *              to exit the program.  Obviously it doesn't test all of       *
  7.  *              all of IBMCOM, but it tests the most important parts --      *
  8.  *              receiving and sending characters.                            *
  9.  *                                                                           *
  10.  * REVISIONS:   18 OCT 89 - RAC - Translated from the Pascal.                *
  11.  *****************************************************************************/
  12.  
  13. #include        <stdio.h>
  14. #include        "ibmcom.h"
  15.  
  16. #define PORT    2
  17. #define SPEED   2400
  18.  
  19. get_key() {
  20.     int         c;
  21.     if (c = getch()) return c;
  22.     else return getch() + 256;
  23.     }
  24.  
  25. main() {
  26.  
  27.     int herb;
  28.  
  29.     if (herb = com_install(PORT)) {
  30.         printf("com_install() error: %d\n", herb);
  31.         return;
  32.         }
  33.     com_raise_dtr();
  34.     com_set_speed(SPEED);
  35.     com_set_parity(COM_NONE, 1);
  36.     clrscr();
  37.     printf("IBMCOM Test\n");
  38.     while (1) {
  39.         if (kbhit()) {
  40.             herb = get_key();
  41.             if (herb == 301 /* Alt-X */) {
  42.                 com_deinstall();
  43.                 exit();
  44.                 }
  45.             com_tx(herb);
  46.             }
  47.         if (herb = com_rx())
  48.             putchar(herb);
  49.         }
  50.     }
  51.